package gdufs.stat.service.vo;

import java.util.Calendar;
import java.util.Date;

public class Semester {
	
	private String xn;//学年
	
	private int xq;//学期
	
	private Date startDate;//开始时间
	
	private Date endDate;//结束时间
	
	private int ksz;//开始周
	
	private int jsz;//结束周

	public String getXn() {
		return xn;
	}

	public void setXn(String xn) {
		this.xn = xn;
	}

	public int getXq() {
		return xq;
	}

	public void setXq(int xq) {
		this.xq = xq;
	}

	public Date getStartDate() {
		return startDate;
	}
	
	public int getCurrentWeek() {
		int week = 1;
		if (startDate != null) {
			Date current = new Date();
			int days = daysOfTwo(startDate, current);
			week =  days / 7;
			if (days % 7 != 0 ) {
				week++;
			}
		}
		return week;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public int getKsz() {
		return ksz;
	}

	public void setKsz(int ksz) {
		this.ksz = ksz;
	}

	public int getJsz() {
		return jsz;
	}

	public void setJsz(int jsz) {
		this.jsz = jsz;
	}
	
	public static int daysOfTwo(Date fDate, Date oDate) {
       Calendar aCalendar = Calendar.getInstance();

       aCalendar.setTime(fDate);

       int day1 = aCalendar.get(Calendar.DAY_OF_YEAR);

       aCalendar.setTime(oDate);

       int day2 = aCalendar.get(Calendar.DAY_OF_YEAR);

       return (day2-day1);

    }	
}
